`timescale 1ns / 1ps

//////////////////////////////////////////////////////////////////////
////                                                              //// 
////                                                              //// 
////  Parte del proyecto "Controlador de luces de un semaforo"    ////  
////                                                              ////
////                                                              //// 
////  Description                                                 //// 
////  	- Modulo central que comunica a todos lo otros modulos   ////
///      los une mediente wire para su respectiva comunicacion    ////
////                                                              //// 
////  To Do:                                                      //// 
////                                                              //// 
////  Author(s):                                                  //// 
////      - Sergio Gonzalez Q, sergiogq@hotmail.es                ////
////      - Alejandro Morales A, ale3191@gmail.com                //// 
////                                                              //// 
////////////////////////////////////////////////////////////////////// 
////                                                              //// 
//// Copyright (C) 2009 Authors and OPENCORES.ORG                 //// 
////                                                              //// 
//// This source file may be used and distributed without         //// 
//// restriction provided that this copyright statement is not    //// 
//// removed from the file and that any derivative work contains  //// 
//// the original copyright notice and the associated disclaimer. //// 
////                                                              //// 
//// This source file is free software; you can redistribute it   //// 
//// and/or modify it under the terms of the GNU Lesser General   //// 
//// Public License as published by the Free Software Foundation; //// 
//// either version 2.1 of the License, or (at your option) any   //// 
//// later version.                                               //// 
////                                                              //// 
//// This source is distributed in the hope that it will be       //// 
//// useful, but WITHOUT ANY WARRANTY; without even the implied   //// 
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //// 
//// PURPOSE.  See the GNU Lesser General Public License for more //// 
//// details.                                                     //// 
////                                                              //// 
//// You should have received a copy of the GNU Lesser General    //// 
//// Public License along with this source; if not, download it   //// 
//// from http://www.opencores.org/lgpl.shtml                     //// 
////                                                              ////
//////////////////////////////////////////////////////////////////////

/**
- Este modulo esta conectado directamente son el Spartam C, donde tiene como
entradas el reloj que tiene internamente este, el reset, el walk_Request y el 
reprogram que son botones; el sensor, el time_parameter_select, el time_value
 que son switches
- Las salidas que son LEDS (salidas de los semafaros y la de walk); el segment_o es el
tiempo restante que le queda al usuario para cruzar la calle y second_o que es el reloj 
de un segundo 
*/

module tb_SemaphoneControllerLigth;

	//Imputs
	reg clk_i, rst_i, sensor_i, walk_request_i,reprogram_i;
	reg [3:0] time_value_i; // valor a ingresar
	reg [1:0] time_parameter_selector_i; // selecciona el parametro a programar
	
	//Outputs
	wire [3:0] segment_o; // tiempo restante   
	wire [6:0] LDEs_o; // salida de los semafaros y  la de walk (indica que al usuario que puede cruzar la calle)
	wire second_o; // salida de un segundo
	
	SemaphoreControlLight tb_SemaphoneControllerLigth (clk_i,rst_i, time_value_i, time_parameter_selector_i, reprogram_i, 
										walk_request_i, sensor_i,segment_o, LDEs_o,second_o);
				
	
	initial begin
		clk_i = 0;
		forever begin
			clk_i = ~clk_i;
			#20;
		end
	end

	initial begin
		// Initialize Inputs
		clk_i = 0;
		rst_i = 0;
		sensor_i = 0;
		walk_request_i = 0;
		reprogram_i = 0;
	   time_value_i = 0;
	   time_parameter_selector_i = 0;
		
		// Add stimulus here
		#100;
		rst_i = 1;
		#40;
		rst_i = 0;
	
		#40; // Wait 40 ns
		sensor_i = 1;
		#1000000;
		sensor_i = 0;
		
		#40; // Wait 40 ns
		walk_request_i = 1;
		#1000000;
		walk_request_i = 0;
		
		#40; // Wait 40 ns
	   time_value_i = 0;
	   time_parameter_selector_i = 4;
		reprogram_i = 1;
		#1000000;
		reprogram_i = 0;
		
		#40; // Wait 40 ns
		walk_request_i = 1;
		#1000000;
		walk_request_i = 0;
		
		#40; // Wait 40 ns
	   time_value_i = 1;
	   time_parameter_selector_i = 6;
		reprogram_i = 1;
		#1000000;
		reprogram_i = 0;
		
		#40; // Wait 40 ns
		walk_request_i = 1;
		#1000000;
		walk_request_i = 0;
		
		#40; // Wait 40 ns
	   time_value_i = 2;
	   time_parameter_selector_i = 10;
		reprogram_i = 1;
		#1000000;
		reprogram_i = 0;
		
		#40; // Wait 40 ns
		sensor_i = 1;
		#1000000;
		sensor_i = 0;
	end
				
endmodule
